package net.csdn.business.common.oauth2.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import net.csdn.business.common.oauth2.model.entity.OauthCode;
import net.csdn.business.common.domain.request.oauth.OauthCodeQuery;
import net.csdn.business.common.domain.vo.oauth.OauthCodeVO;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 授权码Mapper接口
 * 
 * @author zhangyl
 * @date 2022-11-08
 */
@Repository
public interface OauthCodeMapper extends BaseMapper<OauthCode>
{

    /**
     * 分页查询授权码列表
     *
     * @param query 字典类型信息
     * @return 字典类型集合信息
     */
    @Select("<script>select id, object_id, code, authentication, created_by, created_date, last_modified_by, last_modified_date" +
            " from oauth_code where 1=1" +
            "<if test='query.code != null  and query.code != \"\"'> " +
             "and code = #{query.code}" +
            "</if>" +
            "</script>")
    public List<OauthCodeVO> findPageList(Page page, @Param("query") OauthCodeQuery query);

    /**
     * 查询授权码列表
     * 
     * @param query 授权码
     * @return 授权码集合
     */
    @Select("<script>select id, object_id, code, authentication, created_by, created_date, last_modified_by, last_modified_date" +
            " from oauth_code where 1=1" +
            "<if test='query.code != null  and query.code != \"\"'> " +
            "and code = #{query.code}" +
            "</if>" +
            "</script>")
    public List<OauthCodeVO> selectOauthCodeList(@Param("query") OauthCodeQuery query);


}
